import React, { Component } from 'react'
import {connect} from "react-redux"
import * as action from "../action/index.js"

import {bindActionCreators} from "redux" // 合并抽离出去的action的
 class Hot extends Component {
  seTNAME(){
    this.props.setName()
  }
  componentDidMount(){
    this.props.getList()
  }
  render() {
    console.log(this.props)
    return (
      <div>
        <span>{this.props.name}</span>
        <button onClick={this.seTNAME.bind(this)}>点击</button>
        {
          this.props.arr&&this.props.arr.length?this.props.arr.map((item,index)=>{
            return <div key={index}>{item.name1}</div>
          }):""
        }
      </div>
    )
  }
}
let mapStateToprops = (state)=>{
  console.log(state,111111111111111111)
  return {
    ...state.hotReducer
  }
}
// let mapDispacthToprops = (dispatch)=>{
//     return {
//          setName(){
//             dispatch({
//               type:"setname",
//               payload:"lisi"
//             })
//          }
//     }
// }
let mapDispacthToprops =(dispatch)=>bindActionCreators(action,dispatch)
export default connect(mapStateToprops,mapDispacthToprops)(Hot)